function isNull(obj){
	return obj === null;
}
function isTBD(obj){
	return obj === undefined;
}
function isFun(obj){
	return typeof(obj) === "function";
}
function isString(obj){
	return typeof(obj) === "string";
}
function isBoolean(obj){
	return typeof(obj) === "boolean";
}
function isNumber(obj){
	return typeof(obj) === "number";
}
function isArray(obj){
	return Array.isArray(obj);
}
function isJQuery(obj){
	return window.jQuery != undefined && obj instanceof jQuery;
}
function isElement(obj){
	return obj instanceof Element/* && obj instanceof Node*/;
}
function isEmpty2(obj){
	if(obj == undefined){// 包含 null 和 undefined
		return true;
	}
	if(isString(obj)){// string
		return obj == "" || obj.trim() == "";
	}
	if(isArray(obj) || isJQuery(obj)){// array || jQuery
		return obj.length > 0;
	}
	return false;
}

function isEmpty(obj) {
    if (obj == undefined) { // 包含 null 和 undefined
        return true;
    } else if (typeof obj === "string" || Array.isArray(obj)) {
        return obj.length == 0;
    } else {
        return false;
    }
}

/**
 * 分组
 */
function groupBy(array, key, result = {}) {
    return array.reduce((result, currentValue) => {
        (result[currentValue[key]] = result[currentValue[key]] || []).push(currentValue);
        return result;
    }, result);
}

function guid(){
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        let r = Math.random() * 16 | 0,
            v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
}

function uuid(){
    let s = [];
    let hexDigits = "0123456789abcdef";
    for (var i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
    }
    s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
    s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
    s[8] = s[13] = s[18] = s[23] = "-";
    return s.join("");
}

/**
 * 随机一项在最小(min)与最大(max)之间的数值，默认不包含最大值(calc=0),包含最大值(calc=1)
 * @param {number} min 最小值
 * @param {number} max 最大值
 * @param {number} calc 计算差值
 * @returns {number} 随机一项数值
 */
function randomInt(min = 0, max = 100, calc = 0) {
    min = Math.ceil(min);
    max = Math.floor(max);
    calc = Math.round(calc);
    return Math.floor(Math.random() * (max - min + calc)) + min;
}

/**
 * 随机一项在数组中的项（支持字符串）
 * @param {array} array 数组
 * @returns {object}
 */
function randomEle(array) {
    if(Array.isArray(array) || typeof(array) === "string") {
        let length = array.length;
        if(length != 0){
            let index = randomInt(0, length);
            return array[index];
        }
        return;
    } else {
        return;
    }
    
}